<?php

class Admin_NewsController extends Zend_Controller_Action{
    
    private $_params;
	private $_auth;
	private $_acl;
    public function init(){
        $this->_params      = $this->_request->getParams();                
        $this->_acl         = new My_Acl();
        $this->view->acl    = $this->_acl;
                 
        $this->_auth        = $this->_acl->checkAllowed();                
        $this->view->auth   = $this->_auth;

//        $config = new Zend_Config_Ini(CONFIG_PATH . '/application.ini', APPLICATION_ENV);               
//        $layout = Zend_Layout::getMvcInstance();
//        $layout->disableLayout();        
    }      
    public function indexAction(){
        $modelNews=new Admin_Model_News();
        $newsList=$modelNews->getAllData();
        $this->view->newsList=$newsList;        
    } 
    public function addAction(){
        $form_news = new Admin_Form_News();       
        $modelNewsCat=new Admin_Model_Newscat();        
        $newsCatList=$modelNewsCat->getAllData();                            
        foreach($newsCatList as $newsCat){
            $newsCatArr[$newsCat['catId']]=$newsCat['catName'];
        }
        $form_news->getElement('newscat')->setMultiOptions($newsCatArr);                        
        
        $this->view->form=$form_news;
    }
    public function get_newsitem_by_catidAction(){        
        $id_dm1 = $this->_request->getParam('id');                
        $dm2=new Admin_Model_Tintucitem;
        $dm2=$dm2->getArrWhere($id_dm1);
        foreach($dm2 as $item){
            $arr_dm2[$item[id]]=$item[ten];
        }
        echo json_encode($arr_dm2);        
        $this->_helper->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);                                        
    }
    
        
}



